home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Source Code
/
Visual Basic Source Code.iso
/
vbsource
/
dbcexe
/
names.cls
< prev
next >
Wrap
Text File
|
1999-03-30
|
18KB
|
461 lines
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
End
attribute VB_Name = "Names"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Attribute VB_Ext_KEY = "SavedWithClassBuilder" ,"Yes"
Attribute VB_Ext_KEY = "Top_Level" ,"Yes"
'-- Created in part by DBClass Class Generator, copyright (c) 1997 Dew Design, LLC.
Option explicit
Private Const m_CLASSNAME = "Names.cls"
'-- The class default SQL statement.
Private Const CLS_SQL = "SELECT Names.* FROM Names"
Private m_SQL As String
Private m_WHERE As String
Private m_lFieldSize As Long
Private m_Recordset As Recordset
Private PropertyUpdates As New Collection
'--------------------------------------------------------------------------------------------------------------------------'
'---------- Class Properties -------------------------------'
'--------------------------------------------------------------------------------------------------------------------------'
Public Property Get ID() As Long
On Error Resume Next
ID = PropertyUpdates.Item("ID").Value
If Err.Number = 0 Then Exit Property
Err.Number = 0
On Error GoTo Error_Get_ID
If Not IsNull(m_Recordset!ID) Then _
ID = m_Recordset!ID
Exit Property
Error_Get_ID:
If Not oError(Err.Number, m_CLASSNAME & " : Get ID") Then Resume
End Property
'--------------------------------------------------------------------------------------------------------------------------'
Public Property Let IsNew(ByVal vData As Boolean)
MarkPropertyUpdated "IsNew", "IsNew", vData
End Property
Public Property Get IsNew() As Boolean
On Error Resume Next
IsNew = PropertyUpdates.Item("IsNew").Value
If Err.Number = 0 Then Exit Property
Err.Number = 0
On Error GoTo Error_Get_IsNew
If Not IsNull(m_Recordset!IsNew) Then _
IsNew = m_Recordset!IsNew
Exit Property
Error_Get_IsNew:
If Not oError(Err.Number, m_CLASSNAME & " : Get IsNew") Then Resume
End Property
'--------------------------------------------------------------------------------------------------------------------------'
Public Property Let lname(ByVal vData As String)
m_lFieldSize = m_Recordset!lname.Size
vData = Trim(vData)
If Len(vData) > m_lFieldSize Then
vData = Left(vData, m_lFieldSize)
MsgBox "This Field is limited to "& m_lFieldSize & " characters in length."
End If
MarkPropertyUpdated "lname", "lname", vData
End Property
Public Property Get lname() As String
On Error Resume Next
lname = PropertyUpdates.Item("lname").Value
If Err.Number = 0 Then Exit Property
Err.Number = 0
On Error GoTo Error_Get_lname
If Not IsNull(m_Recordset!lname) Then _
lname = m_Recordset!lname
Exit Property
Error_Get_lname:
If Not oError(Err.Number, m_CLASSNAME & " : Get lname") Then Resume
End Property
'--------------------------------------------------------------------------------------------------------------------------'
Public Property Let fname(ByVal vData As String)
m_lFieldSize = m_Recordset!fname.Size
vData = Trim(vData)
If Len(vData) > m_lFieldSize Then
vData = Left(vData, m_lFieldSize)
MsgBox "This Field is limited to "& m_lFieldSize & " characters in length."
End If
MarkPropertyUpdated "fname", "fname", vData
End Property
Public Property Get fname() As String
On Error Resume Next
fname = PropertyUpdates.Item("fname").Value
If Err.Number = 0 Then Exit Property
Err.Number = 0
On Error GoTo Error_Get_fname
If Not IsNull(m_Recordset!fname) Then _
fname = m_Recordset!fname
Exit Property
Error_Get_fname:
If Not oError(Err.Number, m_CLASSNAME & " : Get fname") Then Resume
End Property
'--------------------------------------------------------------------------------------------------------------------------'
Public Property Let address(ByVal vData As String)
m_lFieldSize = m_Recordset!address.Size
vData = Trim(vData)
If Len(vData) > m_lFieldSize Then
vData = Left(vData, m_lFieldSize)
MsgBox "This Field is limited to "& m_lFieldSize & " characters in length."
End If
MarkPropertyUpdated "address", "address", vData
End Property
Public Property Get address() As String
On Error Resume Next
address = PropertyUpdates.Item("address").Value
If Err.Number = 0 Then Exit Property
Err.Number = 0
On Error GoTo Error_Get_address
If Not IsNull(m_Recordset!address) Then _
address = m_Recordset!address
Exit Property
Error_Get_address:
If Not oError(Err.Number, m_CLASSNAME & " : Get address") Then Resume
End Property
'--------------------------------------------------------------------------------------------------------------------------'
Public Property Let city(ByVal vData As String)
m_lFieldSize = m_Recordset!city.Size
vData = Trim(vData)
If Len(vData) > m_lFieldSize Then
vData = Left(vData, m_lFieldSize)
MsgBox "This Field is limited to "& m_lFieldSize & " characters in length."
End If
MarkPropertyUpdated "city", "city", vData
End Property
Public Property Get city() As String
On Error Resume Next
city = PropertyUpdates.Item("city").Value
If Err.Number = 0 Then Exit Property
Err.Number = 0
On Error GoTo Error_Get_city
If Not IsNull(m_Recordset!city) Then _
city = m_Recordset!city
Exit Property
Error_Get_city:
If Not oError(Err.Number, m_CLASSNAME & " : Get city") Then Resume
End Property
'--------------------------------------------------------------------------------------------------------------------------'
Public Property Let state(ByVal vData As String)
m_lFieldSize = m_Recordset!state.Size
vData = Trim(vData)
If Len(vData) > m_lFieldSize Then
vData = Left(vData, m_lFieldSize)
MsgBox "This Field is limited to "& m_lFieldSize & " characters in length."
End If
MarkPropertyUpdated "state", "state", vData
End Property
Public Property Get state() As String
On Error Resume Next
state = PropertyUpdates.Item("state").Value
If Err.Number = 0 Then Exit Property
Err.Number = 0
On Error GoTo Error_Get_state
If Not IsNull(m_Recordset!state) Then _
state = m_Recordset!state
Exit Property
Error_Get_state:
If Not oError(Err.Number, m_CLASSNAME & " : Get state") Then Resume
End Property
'--------------------------------------------------------------------------------------------------------------------------'
Public Property Let Filter(vData As String)
m_Where = vData
End Property
Public Property Get Filter() As String
Filter = m_Where
End Property
'--------------------------------------------------------------------------------------------------------------------------'
Public Property Let SQL(vData As String)
m_SQL = vData
End Property
Public Property Get SQL() As String
SQL = m_SQL
End Property
'--------------------------------------------------------------------------------------------------------------------------'
'---------- Class Methods ------------------------------'
'--------------------------------------------------------------------------------------------------------------------------'
Public Function Add(Optional addIsNew As String) As Boolean
'-- Adjust the function parameters to whichever fields need to be passed
'-- Be sure to include default record specifics below
Dim iID As Long
On Error GoTo Error_Add
CancelUpdate
BeginTrans
With m_Recordset
.AddNew
'-- Default record specifics here
'!IsNew = addIsNew
!IsNew = True
iID = !ID
.Update
End With
CommitTrans
Add = True
If Not FindFirst("ID = " & iID) Then _
MsgBox "Unable to find the new record!"
Exit Function
Error_Add:
If Not oError(Err.Number, m_CLASSNAME & " : Add") Then Resume
Add = F